//////////////////////////////////////////////
///                                        ///
/// PPA-1 Main Simulation File             ///
///                                        ///
/// Released under CERN Open Hardware      ///
/// License                                ///
///                                        ///
/// Marce Coll 2017 - ppa@marcecoll.com    ///
///                                        ///
//////////////////////////////////////////////


#include "Vppa1_cpu.h"
#include "verilated.h"

#include <iostream>

vluint64_t main_time = 0;


double sc_time_stamp() {
        return main_time;
}

int main(int argc, char **argv, char **env) {
        Verilated::commandArgs(argc, argv);

        Vppa1_cpu* cpu = new Vppa1_cpu;

        cpu->reset = 1;

        while (!Verilated::gotFinish()) {
                if(main_time > 10) {
                        cpu->reset = 0;
                }

                if(main_time % 10 == 1) {
                         cpu->clk = 1;
                }
                else if(main_time % 10 == 6){
                         cpu->clk = 0;
                }

                cpu->eval();

                std::cout << "alu_result: " << cpu->alu_result << std::endl;
                main_time++;
        }

        cpu->final();
        delete cpu;

        exit(0);
}
